package com.intellif.mozping;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;

import java.lang.reflect.Field;
import java.util.ArrayList;

/**
 * @author by mozping
 * @Classname Test
 * @Description TODO
 * @Date 2019/4/16 20:10
 */
public class Test {

    public static void main(String[] args) {

        Field[] fieldsConsumer = ConsumerConfig.class.getDeclaredFields();
        ArrayList<String> consumerArr = new ArrayList<String>();
        for (int i = 0, len = fieldsConsumer.length; i < len; i++) {
            // 对于每个属性，获取属性名
            String varName = fieldsConsumer[i].getName();
            consumerArr.add(varName);
        }
        System.out.println("消费者配置个数为：" + consumerArr.size());


        Field[] fieldsProducer = ProducerConfig.class.getDeclaredFields();
        ArrayList<String> producerArr = new ArrayList<String>();
        for (int i = 0, len = fieldsProducer.length; i < len; i++) {
            // 对于每个属性，获取属性名
            String varName = fieldsProducer[i].getName();
            producerArr.add(varName);
        }

        System.out.println("生产者配置个数为：" + producerArr.size());
        int common = 0;
        for (String config : producerArr) {
            if (consumerArr.contains(config) &&
            !config.contains("DOC")) {
                System.out.println(config);

                common++;
            }
        }

        System.out.println("公共个数为：" + common);
    }
}

